import request from '@/utils/request'

// 用户相关接口

// 获取用户个人信息
export const getUserProfile = () => {
  return request.get('/user/profile')
}

// 检查用户是否已注册
export const checkUserRegistration = (data: {
  code: string
}) => {
  return request.post('/user/check-user', data)
}

// 微信小程序登录
export const miniProgramLogin = (data: {
  code: string
  redirectUri: string
}) => {
  return request.post('/user/mini-login', data)
}

// 邮箱登录
export const emailLogin = (data: {
  email: string
  password: string
}) => {
  return request.post('/auth/email', data)
}

// 刷新token
export const refreshToken = () => {
  return request.post('/auth/refresh')
}

// 用户类型定义
export interface UserProfile {
  id: number
  nickname: string
  avatarUrl: string
  openId: string | null
  email: string
  password: string
  loginType: string
  token: string | null
  role: string
  isPremium: boolean
  createTime: string
  updatedTime: string
}
